import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterOutlet } from '@angular/router';
import { invoke } from '@tauri-apps/api/tauri';
import { appWindow } from '@tauri-apps/api/window';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule, RouterOutlet],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss',
})
export class AppComponent {
  greetingMessage = '';

  greet(event: SubmitEvent, name: string): void {
    event.preventDefault();

    // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
    // invoke<string>('greet', {name}).then((text) => {
    //   this.greetingMessage = text;
    // });

    // let searchOption = {
    //   path: ['~/src'],
    //   include_name: ['\.ts'],
    //   exclude_name: ['\.d\.ts', 'spec\.ts'],
    //   include_content: ['store', 'Collapsed'],
    // };
    // invoke('start_search', {searchOption}).then(r => {
    //   console.log('start_search', r);
    // });
    invoke('test_async_log').then();

    appWindow.listen('timed-event', event1 => {
      let payload = event1.payload;
      console.log('event payload:', payload);
    }).then();
  }
}
